#include <fstream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <unistd.h>
#include "dbc_file_analysis.h"
#include "dbc_canmsg_unpack.h"
#include "dbc_canmsg_pack.h"
#include "canmsg_define.h"
#include "util.h"
#include "can_config_data_path.h"
#include "print_can_msg.h"
using namespace std;

void valuesPack(const long &id, const int valueSize, const double *valueInput, Canmsg *msg)
{

	Message canMsgStruct = dbc_analysis::DbcAnalysis::getInstance()->getMessages()[id];
	can_util::packCanmsg(canMsgStruct, valueSize, valueInput, msg);
	msg->length = canMsgStruct.length;
	msg->id = id;
}

int main()
{
	string folderpath = can_dbcs_path;
	std::vector<std::string> files;
	getAllFilesInFolder(folderpath, &files);
	for (std::string &file : files)
	{
		dbc_analysis::DbcAnalysis::getInstance()->addOneDbcFile(file);
	}

	dbc_analysis::DbcAnalysis::getInstance()->analysisFiles();
	dbc_analysis::DbcAnalysis::getInstance()->printMessages();
	std::vector<double> valueOut1(3);
	//double valueOut1[3];
	/*can_frame test_frame = {0};
	test_frame.can_id = 0x0a0;
	test_frame.can_dlc = 8;
	test_frame.data[0] = 255;
	test_frame.data[1] = 255;
	test_frame.data[2] = 231;
	test_frame.data[3] = 63;
	test_frame.data[4] = 255;
	test_frame.data[5] = 243;
	test_frame.data[6] = 143;
	test_frame.data[7] = 159;
	can_util::unpackCanmsg(dbc_analysis::DbcAnalysis::getInstance()->getMessages()[test_frame.can_id], test_frame, valueOut1);
	for (int i = 0; i < 3; i++)
	{
		printf("%lf ", valueOut1[i]);
	}
	printf("\n");*/
	std::vector<double> signals_value(10, 1.0);
	can_frame msg = {0};
	//int packCanmsg(const Message &m, const std::vector<double> &signals_value, can_frame &msg);
	can_util::packCanmsg(dbc_analysis::DbcAnalysis::getInstance()->getMessages()[0x0a0], signals_value, msg);
	msgPrint(msg);

	return 0;
}
